package cn.b.sky.mes.pp.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.b.sky.mes.pp.model.OperationTask;
import cn.b.sky.mes.pp.model.condition.OperationTaskCondition;
import cn.b.sky.mes.pp.model.condition.OperationTaskConfirmCondition;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.b.sky.common.file.ExcelUtil;
import cn.b.sky.common.model.BatchJobReport;
import cn.b.sky.common.model.DWZResult;
import cn.b.sky.common.utils.DateUtils;
import cn.b.sky.user.SecurityContextUtil;
import cn.b.sky.user.controller.SecurityController;
import cn.b.sky.mes.cm.enums.ECodeEnums;
import cn.b.sky.user.service.ECodeService;
import cn.b.sky.user.service.model.ECode;
import cn.b.sky.mes.pp.model.OperationTaskConfirm;
import cn.b.sky.mes.pp.model.OrderType;
import cn.b.sky.mes.pp.service.OperationTaskConfirmService;
import cn.b.sky.mes.pp.service.OperationTaskService;
import cn.b.sky.mes.pp.service.OrderTypeService;

/**
 * 
 * <strong>Title : OperationTaskController.java<br>
 * </strong> <strong>Package : cn.b.sky.mes.pp.controller<br>
 * </strong> <strong>Description : </strong>工序任务单控制器<br>
 * <strong>Create on : 2016-8-2 上午10:47:21<br>
 * </strong>
 * <p>
 * 
 * @author JinQuan.Fu<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 *          <strong>修改历史:</strong><br>
 *          修改人|修改日期|修改描述<br>
 *          -------------------------------------------<br>
 * <br>
 * <br>
 */
@Controller
@RequestMapping(value = "/operationTask/*")
@Slf4j
public class OperationTaskController extends SecurityController {

	@Resource
	OperationTaskService operationTaskService;

	@Resource
	ECodeService eCodeService;

	@Resource
	OrderTypeService orderTypeService;

	@Resource
	OperationTaskConfirmService operationTaskConfirmService;

	/**
	 * 
	 * <strong>Title : operationArrangePlan<br>
	 * </strong> <strong>Description : </strong>工序排产计划查询<br>
	 * <strong>Create on : 2016-8-10 下午3:59:01<br>
	 * </strong>
	 * <p>
	 * 
	 * @param model
	 * @param navTabId
	 * @param condition
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("operationArrangePlan")
	public String operationArrangePlan(Model model, String navTabId,
			@ModelAttribute("condition") OperationTaskCondition condition) {
		condition.setSiteCode(this.getSiteCode());
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		DateUtils dateUtils = DateUtils.getDateUtils(DateUtils.YYYY_MM_DD);
		Date today = new Date();
		if (StringUtils.isBlank(condition.getPlannedStartDateTime())) {
			condition.setPlannedStartDateTime(dateUtils.format(today));
		}
		if (StringUtils.isBlank(condition.getPlannedendDateTime())) {
			condition.setPlannedendDateTime(dateUtils.format(today));
		}
		List<OrderType> orderTypes = orderTypeService.getAllOrderTypes(this
				.getSiteCode());
		List<OperationTask> list = operationTaskService
				.getOperationArrangePlanByCondition(condition);
		int count = operationTaskService
				.getOperationArrangePlanCountByCondition(condition);
		condition.setData(list);
		condition.setTotalCount(count);
		model.addAttribute("orderTypes", orderTypes);
		model.addAttribute("page", condition);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/operationArrangePlan";
	}

	/**
	 * 
	 * <strong>Title : operationArrangePlanToExcel<br>
	 * </strong> <strong>Description : </strong>工序排产计划导出<br>
	 * <strong>Create on : 2016-8-10 下午3:59:16<br>
	 * </strong>
	 * <p>
	 * 
	 * @param response
	 * @param navTabId
	 * @param condition
	 *            void
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping(value = "operationArrangePlanToExcel")
	public void operationArrangePlanToExcel(HttpServletResponse response,
			String navTabId, OperationTaskCondition condition) {
		condition.setSiteCode(this.getSiteCode());
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		condition.setToDay(DateUtils.getDateUtils().getSystemStrDate());
		List<OperationTask> list = operationTaskService
				.getOperationArrangePlanByCondition(condition);
		Map<String, String> map = new LinkedHashMap<String, String>();
		String languageCode = SecurityContextUtil.getLanguageCode();
		map.put("operationTaskNum",
				getImeViewMessageI18n(languageCode, "operationTaskNum.C"));
		map.put("materialCode",
				getImeViewMessageI18n(languageCode, "materialCode.C"));
		map.put("materialText",
				getImeViewMessageI18n(languageCode, "materialText.C"));
		map.put("plannedWorkUnitCode",
				getImeViewMessageI18n(languageCode, "plannedWorkUnitCode.C"));
		map.put("plannedWorkUnitText",
				getImeViewMessageI18n(languageCode, "plannedWorkUnitText.C"));
		map.put("operationCode",
				getImeViewMessageI18n(languageCode, "operationCode.C"));
		map.put("operationText",
				getImeViewMessageI18n(languageCode, "operationText.C"));
		map.put("plannedQuantity",
				getImeViewMessageI18n(languageCode, "plannedQuantity.C"));
		map.put("plannedStartDateTime",
				getImeViewMessageI18n(languageCode, "plannedstartDateTime.C"));
		map.put("plannedEndDateTime",
				getImeViewMessageI18n(languageCode, "plannedendDateTime.C"));
		map.put("workCenterCode",
				getImeViewMessageI18n(languageCode, "workCenterCode.C"));
		map.put("workCenterText",
				getImeViewMessageI18n(languageCode, "workCenterText.C"));
		map.put("productionControlNum",
				getImeViewMessageI18n(languageCode, "productionControlNum.C"));
		map.put("productionOrderNum",
				getImeViewMessageI18n(languageCode, "productionOrderNum.C"));
		String operationTaskReport = getImeViewMessageI18n(languageCode,
				"operationArrangePlanReport.C");
		try {
			ExcelUtil.exportToExcel(response, operationTaskReport, map, list);
		} catch (IOException e) {
			log.error("{}", e);
		}
	}

	/**
	 * 
	 * <strong>Title : viewOperationArrangePlan<br>
	 * </strong> <strong>Description : </strong>工序排产计划详情<br>
	 * <strong>Create on : 2016-8-10 下午3:59:28<br>
	 * </strong>
	 * <p>
	 * 
	 * @param model
	 * @param navTabId
	 * @param operationTaskNum
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("viewOperationArrangePlan")
	public String viewOperationArrangePlan(Model model, String navTabId,
			String operationTaskNum) {
		OperationTask operationTask = operationTaskService.getOperationTask(
				this.getSiteCode(), operationTaskNum);
		List<ECode> ecode = eCodeService.selectECodeList(
				ECodeEnums.OPERATIONTASK_STATUS.getCode(),
				SecurityContextUtil.getLanguageCode());
		List<OrderType> orderTypes = orderTypeService.getAllOrderTypes(this
				.getSiteCode());
		model.addAttribute("orderTypes", orderTypes);
		model.addAttribute("operationTaskStatus", ecode);
		model.addAttribute("operationTask", operationTask);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/viewOperationArrangePlan";
	}

	/**
	 * 
	 * <strong>Title : operationTaskProgress<br>
	 * </strong> <strong>Description : </strong>工序任务单进度<br>
	 * <strong>Create on : 2016-8-10 上午9:22:23<br>
	 * </strong>
	 * <p>
	 * 
	 * @param model
	 * @param navTabId
	 * @param condition
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("operationTaskProgressList")
	public String operationTaskProgress(Model model, String navTabId,
			@ModelAttribute("condition") OperationTaskCondition condition) {
		condition.setSiteCode(this.getSiteCode());
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		condition.setToDay(DateUtils.getDateUtils().getSystemStrDate());
		List<OrderType> orderTypes = orderTypeService.getAllOrderTypes(this
				.getSiteCode());
		List<OperationTask> list = operationTaskService
				.getOperationTaskProgressByCondition(condition);
		int count = operationTaskService
				.getOperationTaskProgressCountByCondition(condition);
		condition.setData(list);
		condition.setTotalCount(count);
		model.addAttribute("orderTypes", orderTypes);
		model.addAttribute("page", condition);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/operationTaskProgress";
	}

	/**
	 * 
	 * <strong>Title : exportOperationTaskProgressToExcel<br>
	 * </strong> <strong>Description : </strong>工序任务单进度导出<br>
	 * <strong>Create on : 2016-8-10 上午9:22:45<br>
	 * </strong>
	 * <p>
	 * 
	 * @param response
	 * @param navTabId
	 * @param condition
	 *            void
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping(value = "exportOperationTaskProgressToExcel")
	public void exportOperationTaskProgressToExcel(
			HttpServletResponse response, String navTabId,
			OperationTaskCondition condition) {
		condition.setSiteCode(this.getSiteCode());
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		condition.setToDay(DateUtils.getDateUtils().getSystemStrDate());
		List<OperationTask> list = operationTaskService
				.getOperationTaskProgressByCondition(condition);
		Map<String, String> map = new LinkedHashMap<String, String>();
		String languageCode = SecurityContextUtil.getLanguageCode();
		map.put("operationTaskNum",
				getImeViewMessageI18n(languageCode, "operationTaskNum.C"));
		map.put("materialCode",
				getImeViewMessageI18n(languageCode, "materialCode.C"));
		map.put("materialText",
				getImeViewMessageI18n(languageCode, "materialText.C"));
		map.put("plannedWorkUnitCode",
				getImeViewMessageI18n(languageCode, "plannedWorkUnitCode.C"));
		map.put("plannedWorkUnitText",
				getImeViewMessageI18n(languageCode, "plannedWorkUnitText.C"));
		map.put("operationCode",
				getImeViewMessageI18n(languageCode, "operationCode.C"));
		map.put("operationText",
				getImeViewMessageI18n(languageCode, "operationText.C"));
		map.put("plannedQuantity",
				getImeViewMessageI18n(languageCode, "plannedQuantity.C"));
		map.put("completedQuantity",
				getImeViewMessageI18n(languageCode, "completedQuantity.C"));
		map.put("statusText", getImeViewMessageI18n(languageCode, "status.C"));
		map.put("workCenterCode",
				getImeViewMessageI18n(languageCode, "workCenterCode.C"));
		map.put("workCenterText",
				getImeViewMessageI18n(languageCode, "workCenterText.C"));
		map.put("productionControlNum",
				getImeViewMessageI18n(languageCode, "productionControlNum.C"));
		map.put("productionOrderNum",
				getImeViewMessageI18n(languageCode, "productionOrderNum.C"));
		map.put("plannedStartDateTime",
				getImeViewMessageI18n(languageCode, "plannedstartDateTime.C"));
		map.put("plannedEndDateTime",
				getImeViewMessageI18n(languageCode, "plannedendDateTime.C"));
		map.put("actualStartDateTime",
				getImeViewMessageI18n(languageCode, "actualstartDateTime.C"));
		map.put("actualEndDateTime",
				getImeViewMessageI18n(languageCode, "actualendDateTime.C"));

		String operationTaskReport = getImeViewMessageI18n(languageCode,
				"operationTaskReport.C");
		// 循环赋值工序任务单状态信息
		for (OperationTask ot : list) {
			if (null != ot.getOutputStatus()
					&& ot.getOutputStatus().equals(new Integer(0))) {
				ot.setStatusText(getImeViewMessageI18n(languageCode, "normal.C"));
			} else if (null != ot.getOutputStatus()
					&& ot.getOutputStatus().equals(new Integer(1))) {
				ot.setStatusText(getImeViewMessageI18n(languageCode,
						"overdueCompletion.C"));
			} else {
				ot.setStatusText(getImeViewMessageI18n(languageCode,
						"maybeOverdue.C"));
			}
		}
		try {
			ExcelUtil.exportToExcel(response, operationTaskReport, map, list);
		} catch (IOException e) {
			log.error("{}", e);
		}
	}

	/**
	 * 
	 * <strong>Title : viewOperationTaskProgress<br>
	 * </strong> <strong>Description : </strong>工序任务单进度详情<br>
	 * <strong>Create on : 2016-8-10 上午9:23:09<br>
	 * </strong>
	 * <p>
	 * 
	 * @param model
	 * @param navTabId
	 * @param operationTaskNum
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("viewOperationTaskProgress")
	public String viewOperationTaskProgress(Model model, String navTabId,
			String operationTaskNum) {
		OperationTaskConfirmCondition condition = new OperationTaskConfirmCondition();
		condition.setOperationTaskNum(operationTaskNum);
		condition.setSiteCode(this.getSiteCode());
		condition.setOrderField("confirmDateTime");
		condition.setOrderDirection("ASC");
		List<OperationTaskConfirm> list = operationTaskConfirmService
				.getOperationTaskConfirmByCondition(condition);
		int count = operationTaskConfirmService
				.getOperationTaskConfirmCountByCondition(condition);
		condition.setData(list);
		condition.setTotalCount(count);
		model.addAttribute("page", condition);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/viewOperationTaskProgress";
	}

	/**
	 * 
	 * <strong>Title : exportOperationTaskConfirmToExcel<br>
	 * </strong> <strong>Description : </strong>工序任务单进度详情导出<br>
	 * <strong>Create on : 2016-8-10 上午9:23:24<br>
	 * </strong>
	 * <p>
	 * 
	 * @param response
	 * @param navTabId
	 * @param operationTaskNum
	 *            void
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping(value = "exportOperationTaskConfirmToExcel")
	public void exportOperationTaskConfirmToExcel(HttpServletResponse response,
			String navTabId, String operationTaskNum) {
		OperationTaskConfirmCondition condition = new OperationTaskConfirmCondition();
		condition.setOperationTaskNum(operationTaskNum);
		condition.setSiteCode(this.getSiteCode());
		condition.setOrderField("confirmDateTime");
		condition.setOrderDirection("ASC");
		List<OperationTaskConfirm> list = operationTaskConfirmService
				.getOperationTaskConfirmByCondition(condition);
		Map<String, String> map = new LinkedHashMap<String, String>();
		String languageCode = SecurityContextUtil.getLanguageCode();
		map.put("workCenterCode",
				getImeViewMessageI18n(languageCode, "shiftingWorkCenter.C"));
		map.put("workCenterText",
				getImeViewMessageI18n(languageCode, "workCenterDescription.C"));
		map.put("workUnitCode",
				getImeViewMessageI18n(languageCode, "shiftingWorkUnitCode.C"));
		map.put("workUnitText",
				getImeViewMessageI18n(languageCode, "shiftingWorkUnitText.C"));
		map.put("confirmDateTime",
				getImeViewMessageI18n(languageCode, "confirmTime.C"));
		map.put("personnelCode",
				getImeViewMessageI18n(languageCode, "confirmUser.C"));
		map.put("completedQuantity",
				getImeViewMessageI18n(languageCode, "completedQuantity.C"));
		map.put("scrappedQuantity",
				getImeViewMessageI18n(languageCode, "scrappedQuantity.C"));
		String operationTaskReport = getImeViewMessageI18n(languageCode,
				"viewOperationTaskReport.C");
		try {
			ExcelUtil.exportToExcel(response, operationTaskReport, map, list);
		} catch (IOException e) {
			log.error("{}", e);
		}
	}

	/**
	 * 
	 * <strong>Title : operationTask_list<br>
	 * </strong> <strong>Description : </strong>工序任务单列表<br>
	 * <strong>Create on : 2016-8-10 上午9:23:39<br>
	 * </strong>
	 * <p>
	 * 
	 * @param model
	 * @param navTabId
	 * @param condition
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("operationTask_list")
	public String operationTask_list(Model model, String navTabId,
			@ModelAttribute("condition") OperationTaskCondition condition) {
		List<ECode> ecode = eCodeService.selectECodeList(
				ECodeEnums.OPERATIONTASK_STATUS.getCode(),
				SecurityContextUtil.getLanguageCode());
		condition.setSiteCode(this.getSiteCode());
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		List<OrderType> orderTypes = orderTypeService.getAllOrderTypes(this
				.getSiteCode());
		List<OperationTask> list = operationTaskService
				.getOperationTaskByCondition(condition);
		int count = operationTaskService
				.getOperationTaskCountByCondition(condition);
		condition.setData(list);
		condition.setTotalCount(count);
		model.addAttribute("orderTypes", orderTypes);
		model.addAttribute("operationTaskStatus", ecode);
		model.addAttribute("page", condition);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/operationTask_list";
	}

	/**
	 * 
	 * <strong>Title : viewOperationTask<br>
	 * </strong> <strong>Description : </strong>工序任务单详情<br>
	 * <strong>Create on : 2016-8-10 上午9:24:11<br>
	 * </strong>
	 * <p>
	 * 
	 * @param navTabId
	 * @param model
	 * @param condition
	 * @return String
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("viewOperationTask")
	public String viewOperationTask(String navTabId, Model model,
			@ModelAttribute("condition") OperationTaskConfirmCondition condition) {
		OperationTask operationTask = operationTaskService.getOperationTask(
				this.getSiteCode(), condition.getOperationTaskNum());
		condition.setSiteCode(this.getSiteCode());
		condition.setOrderField("confirmDateTime");
		condition.setOrderDirection("ASC");
		List<ECode> ecode = eCodeService.selectECodeList(
				ECodeEnums.OPERATIONTASK_STATUS.getCode(),
				SecurityContextUtil.getLanguageCode());
		List<OrderType> orderTypes = orderTypeService.getAllOrderTypes(this
				.getSiteCode());
		List<OperationTaskConfirm> list = operationTaskConfirmService
				.getOperationTaskConfirmByCondition(condition);
		int count = operationTaskConfirmService
				.getOperationTaskConfirmCountByCondition(condition);
		condition.setData(list);
		condition.setTotalCount(count);
		model.addAttribute("orderTypes", orderTypes);
		model.addAttribute("operationTaskStatus", ecode);
		model.addAttribute("page", condition);
		model.addAttribute("operationTask", operationTask);
		model.addAttribute(NAVTABID, navTabId);
		return "pp/operationTask/viewOperationTask";
	}

	/**
	 * 
	 * <strong>Title : releaseOperationTask<br>
	 * </strong> <strong>Description : </strong>下达<br>
	 * <strong>Create on : 2016-8-2 下午1:18:01<br>
	 * </strong>
	 * <p>
	 * 
	 * @param navTabId
	 * @param model
	 * @return DWZResult
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("releaseOperationTask")
	@ResponseBody
	public DWZResult releaseOperationTask(String navTabId, Model model,
			String operationTaskNums, HttpServletRequest request) {
		String[] idArr = operationTaskNums.split(",");
		List<BatchJobReport> reports = new ArrayList<BatchJobReport>();
		int failures = 0;
		for (int i = 0; i < idArr.length; i++) {
			String operationTaskNum = idArr[i];
			String message = null;
			message = operationTaskService.releaseOperationTask(
					this.getSiteCode(), operationTaskNum);
			boolean flag = true;
			if (!StringUtils.isBlank(message)) {
				failures += 1;
				flag = false;
				message = getImeViewMessageI18n(
						SecurityContextUtil.getLanguageCode(), message);
			}
			BatchJobReport report = new BatchJobReport(idArr[i], message, flag);
			reports.add(report);
		}
		if (failures == 0) {
			return navTabAjaxDone(
					navTabId,
					null,
					null,
					null,
					getImeViewMessageI18n(this.getCurrentLanguage(),
							"successfulOperation.M"), null);
		} else {
			return batchjobAjaxDone(request, reports);
		}
	}

	/**
	 * 
	 * <strong>Title : revocationOperationTask<br>
	 * </strong> <strong>Description : </strong>撤销<br>
	 * <strong>Create on : 2016-8-2 下午1:18:41<br>
	 * </strong>
	 * <p>
	 * 
	 * @param navTabId
	 * @param model
	 * @return DWZResult
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("revocationOperationTask")
	@ResponseBody
	public DWZResult revocationOperationTask(String navTabId, Model model,
			String operationTaskNums, HttpServletRequest request) {
		String[] idArr = operationTaskNums.split(",");
		List<BatchJobReport> reports = new ArrayList<BatchJobReport>();
		int failures = 0;
		for (int i = 0; i < idArr.length; i++) {
			String operationTaskNum = idArr[i];
			String message = null;
			message = operationTaskService.revocationOperationTask(
					this.getSiteCode(), operationTaskNum);
			boolean flag = true;
			if (!StringUtils.isBlank(message)) {
				failures += 1;
				flag = false;
				message = getImeViewMessageI18n(
						SecurityContextUtil.getLanguageCode(), message);
			}
			BatchJobReport report = new BatchJobReport(idArr[i], message, flag);
			reports.add(report);
		}
		if (failures == 0) {
			return navTabAjaxDone(
					navTabId,
					null,
					null,
					null,
					getImeViewMessageI18n(this.getCurrentLanguage(),
							"successfulOperation.M"), null);
		} else {
			return batchjobAjaxDone(request, reports);
		}
	}

	/**
	 * 
	 * <strong>Title : closeOperationTask<br>
	 * </strong> <strong>Description : </strong>强制关闭<br>
	 * <strong>Create on : 2016-8-2 下午1:21:42<br>
	 * </strong>
	 * <p>
	 * 
	 * @param navTabId
	 * @param model
	 * @return DWZResult
	 * @throws
	 * @author JinQuan.Fu<br>
	 * @version <strong>v1.0.0</strong><br>
	 * <br>
	 *          <strong>修改历史:</strong><br>
	 *          修改人 | 修改日期 | 修改描述<br>
	 *          -------------------------------------------<br>
	 * <br>
	 * <br>
	 */
	@RequestMapping("closeOperationTask")
	@ResponseBody
	public DWZResult closeOperationTask(String navTabId, Model model,
			String operationTaskNums, HttpServletRequest request) {
		String[] idArr = operationTaskNums.split(",");
		List<BatchJobReport> reports = new ArrayList<BatchJobReport>();
		int failures = 0;

		for (int i = 0; i < idArr.length; i++) {
			String operationTaskNum = idArr[i];
			String message = null;
			message = operationTaskService.closeOperationTask(
					this.getSiteCode(), operationTaskNum);
			boolean flag = true;
			if (!StringUtils.isBlank(message)) {
				failures += 1;
				flag = false;
				message = getImeViewMessageI18n(
						SecurityContextUtil.getLanguageCode(), message);
			}
			BatchJobReport report = new BatchJobReport(idArr[i], message, flag);
			reports.add(report);
		}
		if (failures == 0) {
			return navTabAjaxDone(
					navTabId,
					null,
					null,
					null,
					getImeViewMessageI18n(this.getCurrentLanguage(),
							"successfulOperation.M"), null);
		} else {
			return batchjobAjaxDone(request, reports);
		}
	}
}
